package com.aliyun.heiyu.powermaster.server.encrypt;

import com.aliyun.heiyu.common.util.PropertiesUtil;

public class SM4Util {
    private static String secretKey;
    private static String iv = "UISwD9fW6cFh9SNS";
    private static SM4Utils sm4;

    static {
        secretKey = PropertiesUtil.getValue("jdbcConfig.properties","privateKey");
        sm4 = new SM4Utils();
        sm4.setSecretKey(secretKey);
        sm4.setIv(iv);
    }

    public static String encrypt_CBC(String text){
        return sm4.encryptData_CBC(text);
    }

    public static String decrypt_CBC(String text){
        if(text != null && text.length() <20){
            return text;
        }
        return sm4.decryptData_CBC(text);
    }

    public static void main(String[] args){
        String s = SM4Util.encrypt_CBC("iuosk");
        System.out.println(s);
        String s1 = SM4Util.decrypt_CBC(s);
        System.out.println(s1);
    }
}
